package vn.lumi.smarthome.network;

public abstract class Message { 
	public final static int CMD_NOTHING = 0x00;
	public final static int CMD_APP_LOGIN = 0xA0;
	public final static int CMD_HC_LOGIN_FEEDBACK = 0xA2;
	public final static int CMD_APP_CONTROL_NORMAL = 0xB0;
	public final static int CMD_APP_CONTROL_RGB = 0xB1;
	public final static int CMD_APP_END_CONTROL_RGB = 0xB2;
	public final static int CMD_APP_KEEP_ALIVE = 0xC0;
	public final static int CMD_HC_ACK = 0xF0;
	public final static int CMD_APP_RECONNECT = 0xC1;
	public final static int CMD_HC_UPDATE = 0xB3;
	public final static int CMD_HC_CONFIG = 0xA3;
	public final static int CMD_HC_UPDATE_ALL_DEVICE = 0xA4;
	public final static int CMD_APP_LOGOUT = 0xA2;
	public final static int CMD_APP_CREATE_SCENE = 0xD0;
	public final static int CMD_HC_ACK_SCENE = 0xD2;
	public final static int CMD_APP_DEL_SCENE = 0xD3;
	public final static int CMD_APP_ACTIVATE_SCENE = 0xD4;
	public final static int CMD_APP_CREATE_SCHEDULE = 0xE0;
	public final static int CMD_HC_ACK_SCHEDULE = 0xE1;
	public final static int CMD_APP_DEL_SCHEDULE = 0xE2;
	
	public final static int VARIABLE_LENGTH = 0;
	
	
	protected int Cmd_id = CMD_NOTHING;
	protected int length = 0;
	
	public Message(int cmd_id){
		Cmd_id = cmd_id;
		length = VARIABLE_LENGTH;
	}
	
	public Message(int cmd_id, int len){
		Cmd_id = cmd_id;
		length = len;
	}
	
	public int getCmd_id(){
		return Cmd_id;
	}
	
	public void setCmd_id(int id){
		Cmd_id = id;
	}
	
	//So sanh input co dung la Message khong
	public final boolean isCorrectFormat(byte[] input){
		if(this.length != this.VARIABLE_LENGTH){
			if(input.length == this.length && input[0] == (byte) this.Cmd_id) return true;
			else return false;
		}
		else{
			if(input[0] == (byte) this.Cmd_id) return true;
			else return false;
		}
	}
}


